//
//  PayPasswordView.m
//  PigMarket
//
//  Created by mac on 2019/5/17.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "PayPasswordView.h"
#import "PZXVerificationCodeView.h"

@interface PayPasswordView ()
///**
// passwordInputView
// */
//@property (nonatomic , strong) PZXVerificationCodeView *passwordView;
/**
 hadview
 */
@property (nonatomic , strong) UIView *headView;
/**
 请输入密码
 */
@property (nonatomic , strong) UILabel *headTitle;
/**
 取消Btn
 */
@property (nonatomic , strong) UIButton *cancelBtn;
/**
 line
 */
@property (nonatomic , strong) UIView *line;
@end

static PayPasswordView *instance = nil;
@implementation PayPasswordView

+ (instancetype)sharedInstance {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[PayPasswordView alloc] init];
    });
    return instance;
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}
//- (void)showPasswordView {
//    [self initView];
//    [self initLayout];
//}
- (void)initView {
    // 添加子控件
    [self addSubview:self.headView];
    [self.headView addSubview:self.headTitle];
    [self.headView addSubview:self.cancelBtn];
    [self.headView addSubview:self.line];
    [self addSubview:self.passwordView];
}

- (void)initLayout {
    // 布局子控件

    [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(0);
        make.height.mas_equalTo(50);
    }];
    [self.headTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(self.headView.mas_centerY);
        make.height.mas_equalTo(22);
    }];
    [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(self.headView.mas_centerY);
        make.height.mas_equalTo(22);
    }];
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(1);
        make.bottom.mas_equalTo(-1);
    }];
}
- (void)hide {
    [self removeFromSuperview];
}
#pragma mark - getter and setter
- (UIView *)headView {
    if (!_headView) {
        _headView = [[UIView alloc] init];
    }
    return _headView;
}
- (UILabel *)headTitle {
    if (!_headTitle) {
        _headTitle = [[UILabel alloc] init];
        _headTitle.textColor = [UIColor textBlackColor];
        _headTitle.font = [UIFont largerFont];
        _headTitle.text = @"请选择豚券";
    }
    return _headTitle;
}
- (UIButton *)cancelBtn {
    if (!_cancelBtn) {
        _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
        [_cancelBtn setTitleColor:[UIColor primaryColor] forState:UIControlStateNormal];
        _cancelBtn.titleLabel.font = [UIFont largerFont];
    }
    return _cancelBtn;
}
- (UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.08];
    }
    return _line;
}
//- (PZXVerificationCodeView *)passwordView {
//    if (!_passwordView) {
//        CGFloat x = 30;
//        CGFloat y = 82;//CGRectGetMaxY(self.titleLab.size) + 25;
//        _passwordView = [[PZXVerificationCodeView alloc] initWithFrame:CGRectMake(x, y, (SCREEN_WIDTH - 60), (SCREEN_WIDTH - 60)/6)];
//        _passwordView.selectedColor = [UIColor blackColor];
//        //        _passwordView.center = self.view.center;
//        _passwordView.VerificationCodeNum = 6;
//        _passwordView.isSecure = YES;
//        _passwordView.Spacing = 0;
//    }
//    return _passwordView;
//}
@end
